import Vue from 'vue'
import {
    addShowAllToFirst,
    baseFormatOptionLabel,
    DICT_DATA_CSS_CLASS,
    CHANGE_BIT_FLAG,
    clearFormValidate,
    equalsObj,
    findRowIndexInListFromAttrName,
    formatOssUrl,
    ifNull,
    isInArray,
    isInvalid,
    isNullOrUndefined,
    mergeFromObject,
    notNullAndNotUndefined,
    parseTime,
    resetSksTableBefore,
    safeGet,
    safeGetNullEmpty,
    safeGetStr,
    setSksTableDataByPage,
    strIfEmpty,
    strIsEmpty,
    strLength,
    generateUUID,
    initListVueVirtualUUID,
    genRowVueVirtualUUID,
    deepCopy,
    objToJsonString,
    dictValueTypeToInteger,
    resetBlank,
    bitFlagToArray,
    bitFlagToStringArray,
    arrayToBitFlag,
    bitFlagAndNumber,
    getIndexByUUIDTable,
    deleteFromVueVirtualUUID,
    getNewChangeRowList,
    initRowVueVirtualUUID,
    strTrim,
    numberIsNotZeroOrNull,
    numberIsZeroOrNull, arrayIsEmpty, initTreeVueVirtualUUID
} from "./lib/core";
import {newTableColumnList} from "./lib/sks-model-utils";
import './lib/style/sks-main.css'
import './lib/style/element-ui.css'
import {isExternal} from "./lib/validate";
import {msgError, msgInfo, msgLoading, msgSuccess} from "./lib/modal";
import {resetForm} from "./lib/ref";
import {absNumber, negateNumber} from "./lib/sks-number-utils";
import {request, sksConfig} from "./lib/sksConfig";
import {addOrUpdateRow, deleteRow, rowStyleElTable} from "./lib/sks-app-utils";
import {simulateFilterByQueryParams} from "./lib/sks-mock-utils";


const sksUtils={
    parseTime,
    notNullAndNotUndefined,
    isNullOrUndefined,
    ifNull,
    equalsObj,
    baseFormatOptionLabel,
    isExternal,
    safeGet,
    safeGetStr,
    safeGetNullEmpty,
    formatOssUrl,
    mergeFromObject,
    deepCopy,
    objToJsonString,
    isInArray,
    findRowIndexInListFromAttrName,
    isInvalid,
    dictValueTypeToInteger,
    addShowAllToFirst,
    resetBlank,
    bitFlagToArray,
    bitFlagToStringArray,
    arrayToBitFlag,
    bitFlagAndNumber,
    arrayIsEmpty,

    //str
    strTrim,
    strIsEmpty,
    strIfEmpty,
    strLength,

    //math
    multiplyNullIsZero,
    divideNullIsZero,
    sumNullIsZero,
    toNumberNullIsZero,
    subtractNullIsZero,
    bignumberToFixed,
    sumFormTableList,
    calcPercentageProgressValue,
    calcTaxCost,
    calcNotTaxCost,

    //modelUtils
    newTableColumnList,

    //numberUtils
    negateNumber,
    absNumber,
    numberIsNotZeroOrNull,
    numberIsZeroOrNull,

    //sksTable
    resetSksTableBefore,
    setSksTableDataByPage,
    rowStyleElTable,
    generateUUID,
    initTreeVueVirtualUUID,
    initListVueVirtualUUID,
    initRowVueVirtualUUID,
    genRowVueVirtualUUID,
    simulateFilterByQueryParams,
    getIndexByUUIDTable,
    deleteFromVueVirtualUUID,
    getNewChangeRowList,
    addOrUpdateRow,
    deleteRow,

    //modal
    msgError,
    msgSuccess,
    msgLoading,
    msgInfo,



    //constants
    CHANGE_BIT_FLAG,
    DICT_DATA_CSS_CLASS,
}


Vue.prototype.clearFormValidate=clearFormValidate
//ref
Vue.prototype.resetForm=resetForm

Vue.prototype.sksUtils=sksUtils

//配置信息,基础配置/缓存配置
Vue.prototype.sksConfig=sksConfig

import SksButton from "./lib/ui/sks-button/index.vue";
import SksButtonTooltip from './lib/ui/sks-button-tooltip/index.js'
import SksDateYmdRange from "./lib/ui/sks-date-ymd-range/index.vue";
import SksImageUseImgUrl from './lib/ui/sks-image-use-img-url/index.js'
import SksTablePropTable from './lib/ui/core/sks-table-prop-table.vue'
import SksDictLabelTag from './lib/ui/sks-dict-label-tag/index.js'
import SksRightToolbar from './lib/ui/sks-right-toolbar/index.js'
import SksTable from './lib/ui/sks-table/index.js'
import SksPagination from './lib/ui/sks-pagination/index.js'
import SksSelectSingleByLookupController from './lib/ui/sks-select-single-by-lookup-controller/index.js'
import SksSelectMultipleByLookupController from "./lib/ui/sks-select-multiple-by-lookup-controller/index.js";
import SksRadioSingleByLookupController from "./lib/ui/sks-radio-single-by-lookup-controller/src";
import SksFilterParamDateRange from "./lib/ui/filter-param/sks-filter-param-date-range/index.js";
import SksFilterParamInput from "./lib/ui/filter-param/sks-filter-param-input/index.js";
import SksFilterParamDictSelect from "./lib/ui/filter-param/sks-filter-param-dict-select/index.js";
import SksCheckbox from './lib/ui/sks-checkbox/index.js'
import SksDate from './lib/ui/sks-date/index.js'
import SksStatusSelect from './lib/ui/sks-status-select/index.js'
import SksTableQueryFormEl from './lib/ui/sks-table-query-form-el/index.js'
import SksSelectMultipleToBitValue from './lib/ui/sks-select-multiple-to-bit-value/index.js'
import SksCacheTable from "./lib/ui/sks-cache-table/index.js";
import SksHtmlMessagePromptDialog from "./lib/ui/sks-html-message-prompt-dialog/index.js";

import {
    bignumberToFixed, calcNotTaxCost, calcPercentageProgressValue, calcTaxCost,
    divideNullIsZero,
    multiplyNullIsZero,
    subtractNullIsZero, sumFormTableList,
    sumNullIsZero,
    toNumberNullIsZero
} from "./lib/sks-number-math";




const components = [
    SksButton,
    SksButtonTooltip,
    SksDateYmdRange,
    SksImageUseImgUrl,
    SksTablePropTable,
    SksDictLabelTag,
    SksRightToolbar,
    SksTable,
    SksPagination,
    SksSelectSingleByLookupController,
    SksSelectMultipleByLookupController,
    SksRadioSingleByLookupController,
    SksFilterParamDateRange,
    SksFilterParamInput,
    SksFilterParamDictSelect,
    SksCheckbox,
    SksDate,
    SksStatusSelect,
    SksTableQueryFormEl,
    SksSelectMultipleToBitValue,
    SksCacheTable,
    SksHtmlMessagePromptDialog,
]


const install = function(Vue, opts = {}) {
    components.forEach(component => {
        Vue.component(component.name, component);
    });
    Vue.prototype.$SKS_PLUGIN_EL_ERP = {
        request: opts.request||request
    };
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue);
}

export default {
    version: '1.0.6',
    install,
    SksButton,
    SksButtonTooltip,
    SksDateYmdRange,
    SksImageUseImgUrl,
    SksTablePropTable,
    SksDictLabelTag,
    SksRightToolbar,
    SksTable,
    SksPagination,
    SksSelectSingleByLookupController,
    SksSelectMultipleByLookupController,
    SksRadioSingleByLookupController,
    SksFilterParamDateRange,
    SksFilterParamInput,
    SksFilterParamDictSelect,
    SksCheckbox,
    SksDate,
    SksStatusSelect,
    SksTableQueryFormEl,
    SksSelectMultipleToBitValue,
    SksCacheTable,
    SksHtmlMessagePromptDialog,
}
